* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: Arial, sans-serif;
    background-color: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.game-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    justify-content: space-between;
}

.game-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 10px 0;
    gap: 10px;
}

.game-area {
    position: relative;
    overflow: visible;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-info {
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    padding: 8px;
    color: #33ff33;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 5px rgba(51, 255, 51, 0.7);
    border: 1px solid rgba(51, 255, 51, 0.5);
    min-width: 100px;
    max-width: 150px;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.game-border {
    position: relative;
    padding: 5px;
    background: linear-gradient(135deg, #555, #333);
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border: 3px solid #222;
    overflow: hidden;
}

.game-border::before {
    content: "TETRIS";
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #222;
    color: #33ff33;
    padding: 2px 15px;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 14px;
    border-radius: 5px;
    letter-spacing: 2px;
    border: 2px solid #33ff33;
    text-shadow: 0 0 5px rgba(51, 255, 51, 0.7);
    z-index: 2;
}

.game-border::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg,
            transparent 0%,
            rgba(255, 255, 255, 0.05) 25%,
            transparent 50%,
            rgba(255, 255, 255, 0.05) 75%,
            transparent 100%);
    pointer-events: none;
    z-index: 1;
}

.game-screen {
    position: relative;
    background-color: #000;
    border: 1px solid #111;
    border-radius: 3px;
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}

.game-screen::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(0deg,
            rgba(0, 0, 0, 0) 0px,
            rgba(0, 0, 0, 0) 1px,
            rgba(255, 255, 255, 0.03) 1px,
            rgba(255, 255, 255, 0.03) 2px);
    pointer-events: none;
    z-index: 3;
    opacity: 0.5;
}

#tetris {
    background-color: #000;
    position: relative;
    height: 100%;
    max-height: calc(100% - 10px);
    max-width: 500px;
    display: block;
    z-index: 1;
}

.stats {
    margin-bottom: 10px;
}

.stats div {
    margin-bottom: 5px;
}

.next-piece-container {
    text-align: center;
    margin-top: auto;
}

.next-piece-container p {
    margin-bottom: 5px;
}

#next-piece-display {
    width: 80px;
    height: 80px;
    background-color: rgba(0, 0, 0, 0.5);
    margin: 0 auto;
    position: relative;
    border: 1px solid rgba(51, 255, 51, 0.5);
}

.controls-container {
    width: 100%;
    padding: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #111;
    border-top: 2px solid #333;
    flex-shrink: 0;
}

.game-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 100px;
    width: 100%;
    max-width: 400px;
    justify-content: center;
}

.game-buttons button {
    flex: 1;
    max-width: 120px;
    height: 30px;
    font-size: 14px;
    background-color: #444;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 3px 0 #222;
}

.game-buttons button:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #222;
}

/* 复古游戏手柄样式 */
.retro-gamepad {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    padding: 0 20px;
    margin-bottom: 5px;
}

.dpad {
    position: relative;
    width: 120px;
    height: 120px;
    max-height: 120px;
}

.dpad button {
    position: absolute;
    width: 40px;
    height: 40px;
    background-color: #333;
    color: #fff;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    box-shadow: 0 3px 0 #111;
}

.dpad button:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #111;
}

.dpad-center {
    position: absolute;
    width: 40px;
    height: 40px;
    background-color: #222;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
}

.dpad-left {
    top: 40px;
    left: 0;
    border-radius: 4px 0 0 4px;
}

.dpad-right {
    top: 40px;
    right: 0;
    border-radius: 0 4px 4px 0;
}

.dpad-up {
    top: 0;
    left: 40px;
    border-radius: 4px 4px 0 0;
}

.dpad-down {
    bottom: 0;
    left: 40px;
    border-radius: 0 0 4px 4px;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
}

.action-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #e74c3c;
    color: white;
    font-size: 18px;
    font-weight: bold;
    border: none;
    box-shadow: 0 4px 0 #c0392b;
    display: flex;
    justify-content: center;
    align-items: center;
}

.action-btn:nth-child(2) {
    background-color: #3498db;
    box-shadow: 0 4px 0 #2980b9;
}

.action-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #c0392b;
}

.action-btn:nth-child(2):active {
    box-shadow: 0 1px 0 #2980b9;
}

/* 响应式设计 - 移动端特殊调整 */
@media (max-width: 768px) {
    .game-wrapper {
        padding: 5px 0;
    }

    .game-border {
        padding: 3px;
    }

    .game-border::before {
        font-size: 12px;
        padding: 1px 10px;
        top: -8px;
    }

    .game-info {
        font-size: 12px;
        padding: 5px;
        min-width: 80px;
    }

    #next-piece-display {
        width: 60px;
        height: 60px;
    }

    .dpad {
        width: 100px;
        height: 100px;
    }

    .dpad button {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }

    .dpad-center {
        width: 30px;
        height: 30px;
    }

    .dpad-left {
        top: 32.5px;
    }

    .dpad-right {
        top: 32.5px;
    }

    .dpad-up {
        left: 32.5px;
    }

    .dpad-down {
        left: 32.5px;
    }

    .action-btn {
        width: 45px;
        height: 45px;
        font-size: 16px;
    }

    .game-buttons button {
        height: 28px;
        font-size: 12px;
    }
}

/* 小屏幕设备特殊调整 */
@media (max-width: 320px) {
    .game-wrapper {
        gap: 5px;
    }

    .game-border {
        padding: 2px;
        border-width: 2px;
    }

    .game-border::before {
        font-size: 10px;
        padding: 1px 8px;
        top: -6px;
        letter-spacing: 1px;
    }

    .game-screen {
        border-width: 1px;
    }

    .game-info {
        font-size: 10px;
        padding: 4px;
        min-width: 70px;
    }

    #next-piece-display {
        width: 50px;
        height: 50px;
    }

    .dpad {
        width: 90px;
        height: 90px;
    }

    .dpad button {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .dpad-center {
        width: 25px;
        height: 25px;
    }

    .dpad-left {
        top: 30px;
    }

    .dpad-right {
        top: 30px;
    }

    .dpad-up {
        left: 30px;
    }

    .dpad-down {
        left: 30px;
    }

    .action-btn {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }

    .game-buttons {
        gap: 5px;
    }

    .game-buttons button {
        height: 25px;
        font-size: 11px;
    }

    .retro-gamepad {
        padding: 0 10px;
    }
}

/* 横屏模式调整 */
@media (orientation: landscape) {
    .game-wrapper {
        flex-direction: row;
        justify-content: center;
        align-items: center;
    }

    .game-info {
        height: auto;
        max-height: 80vh;
    }

    .controls-container {
        flex-direction: row;
        justify-content: center;
        gap: 20px;
        padding: 5px;
    }

    .game-buttons {
        flex-direction: column;
        width: auto;
        margin-bottom: 0;
        margin-right: 20px;
    }

    .game-buttons button {
        margin-bottom: 5px;
    }

    .retro-gamepad {
        max-width: 350px;
    }

    .dpad {
        width: 90px;
        height: 90px;
    }

    .dpad button {
        width: 30px;
        height: 30px;
    }

    .dpad-center {
        width: 25px;
        height: 25px;
    }

    .action-btn {
        width: 40px;
        height: 40px;
    }
}